import Vue from 'vue'
import App from '@/App'
import router from '@/router' // api: https://github.com/vuejs/vue-router
import store from '@/store' // api: https://github.com/vuejs/vuex
import VueCookie from 'vue-cookie' // api: https://github.com/alfhen/vue-cookie
import '@/element-ui' // api: https://github.com/ElemeFE/element
import '@/icons' // api: http://www.iconfont.cn/
import '@/element-ui-theme'
import '@/assets/scss/index.scss'
import httpRequest from '@/utils/httpRequest' // api: https://github.com/axios/axios
import {isAuth} from '@/utils'
import cloneDeep from 'lodash/cloneDeep'
import axios from 'axios'
import plugins from './plugins' // plugins
import {VeLine} from 'v-charts/lib/index.esm'
// import Cookies from 'js-cookie'
// import './assets/styles/element-variables.scss'
// import '@/assets/styles/index.scss' // global css
// import '@/assets/styles/ruoyi.scss' // ruoyi css
//工序排产
import Element from 'element-ui'
import './assets/icons' // icon
import directive from './directive' // directive
// 分页组件
import Pagination from "@/components/P3/Pagination";
// 自定义表格工具组件
import RightToolbar from "@/components/P3/RightToolbar"
// 富文本组件
import Editor from "@/components/P3/Editor"
// 文件上传组件
import FileUpload from "@/components/P3/FileUpload"
// 图片上传组件
import ImageUpload from "@/components/P3/ImageUpload"
// 图片预览组件
import ImagePreview from "@/components/P3/ImagePreview"
// 字典标签组件
import DictTag from '@/components/P3/DictTag'
// 头部标签组件
import VueMeta from 'vue-meta'
// 字典数据组件
import DictData from '@/components/P3/DictData'
import webSite from '@/config/website'
import {getDicts} from "@/api/system/dict/data";
import {getConfigKey} from "@/api/system/config";
import {addDateRange, handleTree, parseTime, resetForm, selectDictLabel, selectDictLabels} from "@/utils/ruoyi";
import {download} from "./utils/request";


// 全局方法挂载
Vue.prototype.getDicts = getDicts
Vue.prototype.getConfigKey = getConfigKey
Vue.prototype.parseTime = parseTime
Vue.prototype.resetForm = resetForm
Vue.prototype.addDateRange = addDateRange
Vue.prototype.selectDictLabel = selectDictLabel
Vue.prototype.selectDictLabels = selectDictLabels
Vue.prototype.download = download
Vue.prototype.handleTree = handleTree

Vue.prototype.website = webSite
// 全局组件挂载
Vue.component('DictTag', DictTag)
Vue.component('Pagination', Pagination)
Vue.component('RightToolbar', RightToolbar)
Vue.component('Editor', Editor)
Vue.component('FileUpload', FileUpload)
Vue.component('ImageUpload', ImageUpload)
Vue.component('ImagePreview', ImagePreview)
Vue.use(directive)
Vue.use(plugins)
Vue.use(VueMeta)
DictData.install()






Vue.use(VueCookie)
Vue.component(VeLine.name, VeLine)
Vue.config.productionTip = false

// var tk = Vue.cookie.get('token')
// 非生产环境, 适配mockjs模拟数据                 // api: https://github.com/nuysoft/Mock
if (process.env.NODE_ENV !== 'production') {
  require('@/mock')
}


// 配置axios的token
axios.defaults.headers.common['token'] = Vue.cookie.get('token')
axios.interceptors.request.use(config => {
  config.headers['token'] = Vue.cookie.get('token') // 请求头带上token
  return config
}, error => {
  return Promise.reject(error)
})


// 挂载全局
Vue.prototype.axios = axios
Vue.prototype.$http = httpRequest // ajax请求方法
Vue.prototype.isAuth = isAuth     // 权限方法


// 保存整站vuex本地储存初始状态
window.SITE_CONFIG['storeState'] = cloneDeep(store.state)
Vue.use(Element)


/* eslint-disable no-new */

new Vue({
  el: '#app',
  router,
  store,
  template: '<App/>',
  components: { App }
})
